""" 计时器 """
import time
import numpy as np 

class Timer():
    def __init__(self):

        self.times = []
        self.start()

    def start(self):
        self.tik = time.time()
    
    def stop(self):
        self.times.append(time.time()- self.tik)
        return self.times[-1]

    def avg(self):
        return sum(self.times)/len(self.times)
    
    def sum(self):
        return sum(self.times)
    
    def cumsum(self):
        return np.array(self.times).cumsum().tolist()

timer = Timer()

for i in range(3):
    time.sleep(1)

    print(timer.stop())

print(timer.cumsum())